<!doctype html>
<html class="x-admin-sm">
<head>
    <!-- 公共css、js -->
    {include file="public/static" /}
    <!-- 公共css、js end -->
    <style>
        .container .logo{
            text-align: center;
        }
    </style>
    <script>
        // 是否开启刷新记忆tab功能
        //var is_remember = false;
    </script>
</head>
<body class="index">
    <!-- 顶部开始 -->
    <div class="container">
        <div class="logo">
            <a href="{:url('Index/index')}">{$webInfo.sy_website}</a>
        </div>
        <div class="left_open">
            <a><i title="展开/收起" class="iconfont">&#xe668;</i></a>
        </div>
        <ul class="layui-nav right" lay-filter="">
            <li class="layui-nav-item">
                <a href="javascript:;" onClick="common.openWindow('系统消息','{:url('Admin/adminMessage')}','850','620')" title="消息">
                    <i class="iconfont" style="font-size: 20px">&#xe618;</i>
                    <span class="layui-badge" id="message" style="margin: -20px 0 0 -3px;">0</span>
                </a>
            </li>
            <!-- 个人信息 -->
            <li class="layui-nav-item">
                <a href="javascript:;">{$userData.ad_name}</a>
                <dl class="layui-nav-child">
                    <!-- 二级菜单 -->
                    <dd>
                        <a onclick="xadmin.add_tab('个人信息','{:url('Admin/adminInfo')}')">个人信息</a>
                    </dd>
                    <dd>
                        <a onclick="common.alertWindow('确定要退出管理平台吗？','{:url('Login/quitLogin')}')" >退出</a>
                    </dd>
                </dl>
            </li>
            <!-- 主题 -->
            <li class="layui-nav-item">
                <a href="javascript:;">主题</a>
                <dl class="layui-nav-child">
                    <!-- 二级菜单 -->
                    <dd><a onclick="changeTheme('blackWhite')">默认主题1</a></dd>
                    <dd><a onclick="changeTheme('default2')">默认主题2</a></dd>
                    <dd><a onclick="changeTheme('default3')">默认主题3</a></dd>
                    <dd><a onclick="changeTheme('default4')">默认主题4</a></dd>
                    <dd><a onclick="changeTheme('default5')">默认主题5</a></dd>
                    <dd><a onclick="changeTheme('default')">默认主题6</a></dd>
                    <dd><a onclick="changeTheme('redBlue')">红蓝渐变</a></dd>
                    <dd><a onclick="changeTheme('greenBlue')">绿蓝渐变</a></dd>
                </dl>
            </li>
<!--            <li class="layui-nav-item to-index">-->
<!--                <a href="#">首页</a>-->
<!--            </li>-->
        </ul>
    </div>
    <!-- 左侧菜单开始 -->
    <div class="left-nav">
        <div id="side-nav">
            <ul id="nav"></ul>
        </div>
    </div>
    <!-- <div class="x-slide_left"></div> -->
    <!-- 左侧菜单结束 -->
    <div class="page-content">
        <div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="false">
            <ul class="layui-tab-title">
                <li class="home">
                    <i class="layui-icon">&#xe68e;</i>我的桌面</li></ul>
            <div class="layui-unselect layui-form-select layui-form-selected" id="tab_right">
                <dl>
                    <dd data-type="this">关闭当前</dd>
                    <dd data-type="other">关闭其它</dd>
                    <dd data-type="all">关闭全部</dd>
                </dl>
            </div>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <iframe src="{:url('Index/welcome')}" frameborder="0" scrolling="yes" class="x-iframe"></iframe>
                </div>
            </div>
            <div id="tab_show"></div>
        </div>
    </div>
    <div class="page-content-bg"></div>

    <!-- 右侧主体结束 -->
    <script type="text/javascript" src="__static__/js/js.cookie.min.js"></script>
    <script>
        //唯一标识
        var unique = "{$webInfo.webUnique}";
        $(function () {
            //获取cookie
            var css = Cookies.get(unique+'theme');
            //判断是否有cookie
            if(!css) css = "__static__/css/black-white.min.css";
            //设置主题css
            document.getElementById("theme").href = css;
            //获取左侧菜单
            getLeftMenu()
        });
        /*改变主题*/
        function changeTheme(value){
            if(value == 'default') { //黑绿
                var css = "";
            }else if(value == "default2"){ //默认2
                var css = "__static__/css/theme2.css";
            }else if(value == 'default3'){ //默认3
                var css = "__static__/css/theme3.css";
            }else if(value == 'default4'){ //默认4
                var css = "__static__/css/theme4.css";
            }else if(value == 'default5'){ //默认5
                var css = "__static__/css/theme5.css";
            }else if(value == 'redBlue'){ //红绿
                var css = "__static__/css/red-blue.min.css";
            }else if(value == 'greenBlue'){ //绿蓝
                var css = "__static__/css/green-blue.min.css";
            }else{ //默认藏黑与白
                var css = "__static__/css/black-white.min.css";
            }
            document.getElementById("theme").href = css;
            //设置Cookie保存30天
            Cookies.set(unique+'theme', css, { expires: 30 });
        }
        /*接收消息*/
        if(typeof(EventSource) !== "undefined") {
            var source = new EventSource("{:url('Admin/getMessage')}");
            source.onmessage = function(event){
                //如果有消息
                var data = JSON.parse(event.data);
                if(data.noRead > 0){
                    document.getElementById("message").innerHTML = data.noRead;
                    //如果有未发送消息
                    if(data.noSend > 0) {
                        //浏览器通知事件
                        if (window.Notification && Notification.permission !== "denied") {
                            Notification.requestPermission(function (status) {
                                var message = new Notification('{$webInfo.sy_website}', {
                                    body: '您有新的通知，请在系统消息中查看',
                                    icon: "__static__/images/icon.jpg"
                                });
                                //显示是执行
                                message.onshow = function () {
                                    var Music = new Audio("__static__/music/123.mp3");
                                    Music.play();
                                };
                                //点击后该网页跳转到指定url
                                message.onclick = function () {
                                    message.close();
                                };
                            });
                        }
                    }
                }else{
                    document.getElementById("message").innerHTML = data.noRead;
                }
            };
        }
        /*获取左侧菜单*/
        function getLeftMenu(){
            $.ajax({
                type: "POST",
                url: "{:url('Index/index')}",
                success: function(data){
                    if(data.status === 1){
                        var menu = getChildMenu(data.info, true); //渲染左侧菜单
                        $("#nav").append(menu)
                    }else{
                        layer.msg(data.info, {icon:5, time: 1500})
                    }
                }
            })
        }
        /*递归加载子菜单*/
        function getChildMenu(list, first){
            var str = ""
            for(var index in list){
                var item = list[index]
                //是否禁止
                if(item.status == 1){
                    //如果有子菜单
                    var child = "";
                    if(item.child) child = getChildMenu(item.child)
                    //如果没有跳转链接
                    if(!item.url){
                        if(!item.icon) item.icon = "&#xe602;"
                        var html = '   <li>\n' +
                            '           <a href="javascript:;">\n' +
                            '               <i class="iconfont left-nav-li" lay-tips="'+item.title+'">'+item.icon+'</i>\n' +
                            '               <cite>'+item.title+'</cite>\n' +
                            '               <i class="iconfont nav_right_new">&#xe602;</i>\n' +
                            '           </a>'+
                            '           '+child+''+
                            '       </li>'
                        if(!first){
                            str += "<ul class=\"sub-menu\">"+html+"</ul>"
                        }else{
                            str += html
                        }
                    }else{
                        str += '<ul class="sub-menu">' +
                            '       <li>\n' +
                            '           <a onclick="xadmin.add_tab(\''+item.title+'\',\'/adminplatform/'+item.url+'\')">\n' +
                            '               <i class="iconfont">&#xe602;</i>\n' +
                            '               <cite>'+item.title+'</cite>\n' +
                            '           </a>'+
                            '           '+child+''+
                            '       </li>'+
                            '   </ul>'
                    }
                }
            }
            return str
        }
        /*递归加载子菜单*/
        /*function getChildMenuBackup(list, pid){
            var str = ""
            for(var index in list){
                var item = list[index]
                if(!item.url){
                    if(!item.icon) item.icon = "&#xe602;"
                    str ='<ul class="sub-menu">' +
                        '       <li id="menu-'+item.id+'">\n' +
                        '           <a href="javascript:;">\n' +
                        '               <i class="iconfont left-nav-li" lay-tips="'+item.title+'">'+item.icon+'</i>\n' +
                        '               <cite>'+item.title+'</cite>\n' +
                        '               <i class="iconfont nav_right_new">&#xe602;</i>\n' +
                        '           </a>'+
                        '       </li>' +
                        '</ul>'
                }else{
                    str = '<ul class="sub-menu">' +
                        '       <li id="menu-'+item.id+'">\n' +
                        '           <a onclick="xadmin.add_tab(\''+item.title+'\',\'/adminplatform/'+item.url+'\')">\n' +
                        '               <i class="iconfont">&#xe602;</i>\n' +
                        '               <cite>'+item.title+'</cite>\n' +
                        '           </a>'+
                        '       </li>'+
                        '   </ul>'
                }
                pid > 0 ? $("#menu-"+pid).append(str) : $("#nav").append(str)
                //如果有下级菜单
                if(item.child) getChildMenu(item.child, item.id)
            }
        }*/
    </script>
</body>
</html>